var services = require("../services");
var express = require("express");
var router = express.Router();
const multipart = require('connect-multiparty');
const multipartMiddleware = multipart();

router.post('/data', multipartMiddleware,async function(req, res) {
  console.log(req.files)
  const filePath = req.files.multipartFile.path
  try {
    services.upload(filePath)
    res.send({
      code: 0,
      data: {
        name: req.files.name,
        size: req.files.size
      },
      userMsg: '上传成功！'
    })
  } catch (err) {
    res.send({
      code: 500,
      data: err,
      userMsg: '上传失败：' + err
    })
  }
  
})

module.exports = router;